package sealte.mytable.frame;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jp_north;
	private JPanel jp_center;
	private JPanel jp_south;
	private JLabel jl_columns;
	private JLabel jl_middle;
	private JLabel jl_rows;
	private JTextField jtf_columns;
	private JTextField jtf_rows;
	private JButton jb_showTable;
	private JButton jb_exportExcel;
	private JButton jb_exportTXT;
	private JButton jb_exportXML;
	private JButton jb_save2DB;
	private JTable jt_content;
	private JScrollPane jsp_content;
	
	public MainFrame(){
		jp_north = new JPanel();
		jp_center = new JPanel(new BorderLayout());
		jp_south = new JPanel();
		jl_columns = new JLabel("Columns");
		jl_middle = new JLabel(" * ");
		jl_rows = new JLabel("Rows");
		jtf_columns = new JTextField(3);
		jtf_rows = new JTextField(3);
		jb_showTable = new JButton("Show Table");
		jb_exportExcel = new JButton("Export Excel");
		jb_exportTXT = new JButton("Export TXT");
		jb_exportXML = new JButton("Export XML");
		jb_save2DB = new JButton("Save2DB");
	}
	
	public void instance(){
		this.setTitle("MyTable by SEALTE v0.6");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jp_north.add(jl_rows);
		jp_north.add(jtf_rows);
		jp_north.add(jl_middle);
		jp_north.add(jl_columns);
		jp_north.add(jtf_columns);
		jp_north.add(jb_showTable);
		this.add(jp_north,"North");
		this.add(jp_center,"Center");
		jp_south.add(jb_exportExcel);
		jp_south.add(jb_exportTXT);
		jp_south.add(jb_exportXML);
		jp_south.add(jb_save2DB);
		this.add(jp_south,"South");
		this.setLocation(270, 30);
		this.pack();
		this.setVisible(true);
	}

	public JTextField getJtf_columns() {
		return jtf_columns;
	}

	public JTextField getJtf_rows() {
		return jtf_rows;
	}

	public JButton getJb_showTable() {
		return jb_showTable;
	}

	public JButton getJb_exportExcel() {
		return jb_exportExcel;
	}

	public JButton getJb_exportTXT() {
		return jb_exportTXT;
	}
	
	public JButton getJb_exportXML(){
		return jb_exportXML;
	}
	
	public JButton getJb_save2DB(){
		return jb_save2DB;
	}
	
	public void setJsp_content(JTable jt_content){
		jsp_content = new JScrollPane(jt_content);
	}
	
	public JScrollPane getJsp_content(){
		return jsp_content;
	}
	
	public void setJt_content(int rows, int columns){
		jt_content = new JTable(rows, columns);
	}
	
	public JTable getJt_content(){
		return jt_content;
	}
	
	public JPanel getJp_center() {
		return jp_center;
	}
}
